<?php

class myCredentials extends sfFilter
{
  public function execute ($filterChain)
  {
      $request = $this->getContext()->getRequest();
      $response = $this->getContext()->getResponse();
      $user = $this->getContext()->getUser();

      if($request->getParameter('razred_id') or $request->getParameter('grupa_id'))
      {
        $razreds = $user->getAttribute('razreds');
        if(!in_array($request->getParameter('razred_id'), $razreds) and !in_array($request->getParameter('grupa_id'), $razreds))
          die('Greska, kredencijali razred!!!');
      }

      else if($request->getParameter('skola_id'))
      {
        $skolas = $user->getAttribute('skolas');
        if(!in_array($request->getParameter('skola_id'), $skolas))
          die('Greska, kredencijali skola!!!');
      }

      $filterChain->execute();
  }
}